package com.guochu.pro.service.impl;

import com.guochu.pro.dao.TaskDao;
import com.guochu.pro.entity.Collection;
import com.guochu.pro.dao.CollectionDao;
import com.guochu.pro.service.CollectionService;
import com.guochu.utils.Pagination;
import com.guochu.common.infrastructure.IService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 产品分类表(Collection)表服务实现类
 *
 * @author makejava
 * @since 2021-09-09 01:38:18
 */
@Service
public class CollectionServiceImpl extends IService implements CollectionService {
    @Resource
    private CollectionDao collectionDao;

    @Resource
    private TaskDao uctDao;

    /**
     * 新增数据
     *
     * @param collection 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(Collection collection) {
        this.create(collection);
        return this.collectionDao.insert(collection);
    }

    /**
     * 修改数据
     *
     * @param collection 实例对象
     * @return 实例对象
     */
    @Override
    public int update(Collection collection) {
        return this.collectionDao.update(collection);
    }

    /**
     * 逻辑删除多条记录
     *
     * @param idList 主键
     * @return
     */
    @Override
    public int removeByIds(List<String> idList) {
        return this.collectionDao.removeByIds(idList);
    }

    @Override
    public int deleteById(String id) {
        return this.collectionDao.deleteById(id);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public Collection queryById(String id) {
        return this.collectionDao.queryById(id);
    }

    /**
     * 根据条件查询分页数据
     *
     * @param pagination 分页条件
     * @param limit      查询条件
     * @return 分页数据
     */
    @Override
    public List<Collection> queryPageByLimit(Pagination pagination, Map<String, Object> limit) {
        pagination.setTotal(this.collectionDao.recordCount(limit));
        limit.put("offset", (pagination.getCurrentPage() - 1) * pagination.getPageSize());
        limit.put("pageSize", pagination.getPageSize());
        return this.collectionDao.queryPageByLimit(limit);
    }

    /**
     * 根据条件查询全部数据
     *
     * @param limit 查询条件
     * @return 所有数据
     */
    @Override
    public List<Collection> queryAllByLimit(Map<String, Object> limit) {
        return this.collectionDao.queryAllByLimit(limit);
    }


}
